package cn.lds.j368.dsedu.dto;

import cn.lds.j368.dsedu.constent.DseduConstent;
import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@AllArgsConstructor
@Data
@NoArgsConstructor
public class ResultJson<T> implements Serializable {
	
	private static final long SerialVersionUID = 1l;
	
	private Integer code;
	private String msg;
	private T obj;
	
	public static ResultJson bulidSuccess(Object obj){
		return new ResultJson(DseduConstent.DseduCommonMsg.SYS_SUCCESS_CODE, DseduConstent.DseduCommonMsg.SYS_SUCCESS_MSG,obj);
	}
	
	public static ResultJson bulidError(String msg){
		return new ResultJson(DseduConstent.DseduCommonMsg.SYS_ERROR_CODE,msg,null);
	}
	
	@Override
	public String toString() {
		return JSON.toJSONString(this);
	}
}